<?php
class PostController extends FrontendController
{
	public function actionRead()
	{
		$postId = Yii::app()->request->getParam('id');
		$data = FrontendNewsModel::model()->published()->findByPk($postId);
		$this->render('read',array('data'=>$data));
	}
	public function actionList()
	{
		$this->render('list');
	}
	public function actionSearch()
	{
		$keyword = Yii::app()->request->getParam('keyword');
		$criteria = new CDbCriteria();
		$criteria->compare('title', $keyword, true);
		$criteria->compare('type', 'post');
		$result =  new CActiveDataProvider('FNews', array(
			'criteria' => $criteria,
			'sort'=>array(
            	'defaultOrder'=>'id DESC',
	        ),
	        'pagination'=>array(
	            'pageSize'=>20
	        ),
		));
		$this->render('search', array('result'=>$result, 'keyword'=>$keyword));
	}
}